/*
 * Copyright (c) 2008 Benoit Bouchez, Nicolas Giard
 * 
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package com.noocodecommit.wicket.stuff.jquery.plugin.ui.selectable;

import com.noocodecommit.wicket.stuff.jquery.plugin.JQPluginOptions;

/**
 * JQSelectable Option set
 * 
 * @author Benoit Bouchez
 * 
 */
public class JQSelectableOptions extends JQPluginOptions implements Cloneable
{
	private boolean autoRefresh = true;
	private String filter;

	private String selectedScript = "";
	private String selectingScript = "";
	private String startScript = "";
	private String stopScript = "";
	private String unselectedScript = "";
	private String unselectingScript = "";

	/**
	 * Constructor
	 */
	public JQSelectableOptions()
	{
		super();
		this.setDefaultHeader("selectable");
	}

	/**
	 * Gets the auto refresh value
	 * 
	 * @return the auto refresh value
	 */
	public boolean isAutoRefresh()
	{
		return autoRefresh;
	}

	/**
	 * Sets the auto refresh option value
	 * 
	 * @param autoRefresh
	 *            selectable auto refresh
	 */
	public void setAutoRefresh(boolean autoRefresh)
	{
		this.autoRefresh = autoRefresh;
		this.options.put("autoRefresh", "autorefresh:'" + autoRefresh + "'");
	}

	/**
	 * Gets the filter value
	 * 
	 * @return the filter value
	 */
	public String getFilter()
	{
		return filter;
	}

	/**
	 * Sets the filter option value
	 * 
	 * @param filter
	 *            selectable filter
	 */
	public void setFilter(String filter)
	{
		this.filter = filter;
		this.options.put("filter", "filter:'" + filter + "'");
	}

	/**
	 * Gets the selected script value
	 * 
	 * @return the selected function
	 */
	public String getSelectedScript()
	{
		return selectedScript;
	}

	/**
	 * Sets the selected function
	 * 
	 * @param selectedScript
	 *            selectable selected function
	 */
	public void setSelectedScript(String selectedScript)
	{
		this.selectedScript = selectedScript;
		this.options.put("selected", "selected:function(e, ui){" + selectedScript + "}");
	}

	/**
	 * Gets the selecting script value
	 * 
	 * @return the selecting function
	 */
	public String getSelectingScript()
	{
		return selectingScript;
	}

	/**
	 * Sets the selecting function
	 * 
	 * @param selectingScript
	 *            selectable selecting function
	 */
	public void setSelectingScript(String selectingScript)
	{
		this.selectingScript = selectingScript;
		this.options.put("selecting", "selecting:function(e, ui){" + selectingScript + "}");
	}

	/**
	 * Gets the unselected script value
	 * 
	 * @return the unselected function
	 */
	public String getUnselectedScript()
	{
		return unselectedScript;
	}

	/**
	 * Sets the unselected function
	 * 
	 * @param unselectedScript
	 *            selectable unselected function
	 */
	public void setUnselectedScript(String unselectedScript)
	{
		this.unselectedScript = unselectedScript;
		this.options.put("unselected", "unselected:function(e, ui){" + unselectedScript + "}");
	}

	/**
	 * Gets the unselecting script value
	 * 
	 * @return the unselecting function
	 */
	public String getUnselectingScript()
	{
		return unselectingScript;
	}

	/**
	 * Sets the unselecting function
	 * 
	 * @param unselectingScript
	 *            selectable unselecting function
	 */
	public void setUnselectingScript(String unselectingScript)
	{
		this.unselectingScript = unselectingScript;
		this.options.put("unselecting", "unselecting:function(e, ui){" + unselectingScript + "}");
	}

	/**
	 * Gets the start script value
	 * 
	 * @return the start function
	 */
	public String getStartScript()
	{
		return startScript;
	}

	/**
	 * Sets the start function
	 * 
	 * @param startScript
	 *            selectable start function
	 */
	public void setStartScript(String startScript)
	{
		this.startScript = startScript;
		this.options.put("start", "start:function(e, ui){" + startScript + "}");
	}

	/**
	 * Gets the stop script value
	 * 
	 * @return the stop function
	 */
	public String getStopScript()
	{
		return stopScript;
	}

	/**
	 * Sets the stop function
	 * 
	 * @param stopScript
	 *            selectable stop function
	 */
	public void setStopScript(String stopScript)
	{
		this.stopScript = stopScript;
		this.options.put("stop", "stop:function(e, ui){" + stopScript + "}");
	}

	@Override
	protected Object clone() throws CloneNotSupportedException
	{
		JQSelectableOptions clone = (JQSelectableOptions) super.clone();
		return clone;
	}
}
